WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
string_utils.h
Go to the documentation of this file.
1// WOLF - Copyright (C) 2020-2026
2// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
3// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
4// Joan Vallvé Navarro (jvallve@iri.upc.edu)
5// All rights reserved.
6//
7// This file is part of WOLF: http://www.iri.upc.edu/wolf
8// WOLF is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License version 3
10// as published by the Free Software Foundation.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once
20
21#include <Eigen/Dense>
22#include <ctime>
23#include <iostream>
24#include <string>
25#include <sstream>
26
27namespace wolf
28{
29// date now in string
32std::string dateTimeNow();
33
34inline std::string dateTimeNow()
35{
36 // Get date and time for archiving purposes
37 std::time_t rawtime;
38 std::time(&rawtime);
39 const std::tm* timeinfo = std::localtime(&rawtime);
40 char time_char[30];
41 std::strftime(time_char, sizeof(time_char), "%d/%m/%Y at %H:%M:%S", timeinfo);
42 std::string date_time(time_char);
43 return date_time;
44}
45} // namespace wolf
46
47namespace std
48{
51template <typename Derived>
52std::string to_string(const Eigen::DenseBase<Derived>& mat)
53{
54 std::stringstream ss;
55 if (mat.cols() == 1)
56 ss << mat.transpose();
57 else
58 ss << std::endl << mat;
59 return ss.str();
60}
61} // namespace std
Definition: jet.h:1355
std::string to_string(const Eigen::DenseBase< Derived > &mat)
Returns a string of an Eigen matrix (in a row if it is a column vector)
Definition: string_utils.h:52
Definition: capture_base.h:23
std::string dateTimeNow()
Returns the current date and time as "dd/mm/YYYY at HH:MM:SS".
Definition: string_utils.h:34